add_subdirectory(tools)

add_definitions(-DTRANSLATION_DOMAIN=\"kpipewire5\")

add_executable(WaylandWindowThumbnail)

ecm_qt_declare_logging_category(pipewire_SRCS
                            HEADER logging.h
                            IDENTIFIER PIPEWIRE_LOGGING
                            CATEGORY_NAME pipewire_logging
                            DESCRIPTION "PipeWire components for KDE")

ecm_add_qtwayland_client_protocol_kde(pipewire_SRCS
    PROTOCOL ./protocols/zkde-screencast-unstable-v1.xml
    BASENAME zkde-screencast-unstable-v1
)

target_sources(WaylandWindowThumbnail PRIVATE
    pipewirecore.cpp
    pipewiresourceitem.cpp
    pipewiresourcestream.cpp
    glhelpers.cpp
    pwhelpers.cpp
    ${pipewire_SRCS}
    screencasting.cpp
    screencastingrequest.cpp
    # add more sources here
    main.cpp
    widget.cpp
    resources.qrc
)

target_link_libraries(WaylandWindowThumbnail
    PRIVATE
    Qt${QT_MAJOR_VERSION}::Quick
    Qt${QT_MAJOR_VERSION}::Qml
    Qt${QT_MAJOR_VERSION}::GuiPrivate
    Qt${QT_MAJOR_VERSION}::WaylandClient

    KF5::I18n
    KF5::CoreAddons
    KF5::WaylandClient

    PkgConfig::PipeWire
    epoxy::epoxy
    PkgConfig::GBM
    Wayland::Client)

target_compile_definitions(WaylandWindowThumbnail INTERFACE -DKPW_WITH_SOURCESIZE=1)

if (QT_MAJOR_VERSION EQUAL "5")
    target_link_libraries(WaylandWindowThumbnail PRIVATE Qt5::Gui_EGL)
    if (${Qt5Gui_OPENGL_IMPLEMENTATION} STREQUAL "GLESv2")
        target_link_libraries(WaylandWindowThumbnail PRIVATE Qt5::Gui_GLESv2)
    else()
        target_link_libraries(WaylandWindowThumbnail PRIVATE Qt5::Gui_GL)
    endif()
else()
    target_link_libraries(WaylandWindowThumbnail PRIVATE EGL::EGL)
endif()

